/*
 * @Description: 公共接口调用
 */
import globalData from '@/plugins/data';
import globalMethods from '@/plugins/methods';

export default ({ service, request, tools }) => ({
  /**
   * @description: 获取地址列表
   */
  // COMMON_GET_ADDRESS_LIST() {
  //     mock.onAny('/getAddress').reply((config) => {
  //         // 您可以这样在拦截请求时获取携带的数据
  //         // const data = tools.parse(config.data)
  //         // 模拟正确的返回 并使用 faker 生成假数据
  //         return tools.responseSuccess(data['address-list']);
  //     });
  //     // 如果这个接口不需要模拟了，请使用 request 代替 requestForMock
  //     return requestForMock({
  //         url: '/getAddress',
  //     });
  // },
  /**
   * @description: 获取流程日志
   * @param {*}
   * @return {*}
   */
  getProcessLogs(summaryId) {
    return request({
      url: `${globalMethods.getLocationOrigin()}/seeyon/ajax.do`,
      method: 'post',
      params: {
        method: 'ajaxAction',
        managerName: 'colManager',
        rnd: Math.random()
      },
      data: `managerMethod=getCommentLog&arguments=["${summaryId}"]`
    });
  },
  /**
   * @description: 获取水印
   */
  commonGetWaterMark(appType = 'col') {
    return request({
      url: `${globalMethods.getLocationOrigin()}${
        globalData.ctxPath
      }/rest/waterMark/waterMarkInfo/${appType}/false/true?t=${Math.random()}`
    });
  },

  commonValidateSignature(fileId='',originalFileId='') {
    return request({
      url: `${globalMethods.getLocationOrigin()}${
        globalData.ctxPath
      }/rest/webOffice/getSecuritySeed?recordId=${fileId}&originalFileId=${originalFileId}`
    });
  },

  /**
   * @description: 修改督办
   */
  commonSaveSupervisor(params) {
    return request({
      url: `${globalMethods.getLocationOrigin()}${
        globalData.ctxPath
      }/supervise/supervise.do`,
      method:'post',
      params:{
        method:'saveOrUpdateSupervise',
        rnd: Math.random()
      },
      data:`_json_params=${params}`
    });
  },
  
  /**
   * @description: 检车是否能转发$.i18n("collaboration.grid.alert.noTransSecretData")
   * @param {*}
   * @return {*}
   */
  commonCheckForward(summaryId) {
    return request({
      url: `${globalMethods.getLocationOrigin()}/seeyon/ajax.do`,
      method: 'post',
      params: {
        method: 'ajaxAction',
        managerName: 'secretAjaxManager',
        rnd: Math.random()
      },
      data: `managerMethod=canTransSecretLevel&arguments=[${summaryId}]`
    });
  },
  commonRelationCondition(data) {
    return request({
      url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/rest/coll/cacheUserCondition2Report`,
      method: 'post',
      params: {
        rnd: Math.random()
      },
      data
    });
  },

  commonCheckUserSecret(params) {
    return request({
      url: `${globalMethods.getLocationOrigin()}/seeyon/ajax.do`,
      method: 'post',
      params: {
        method: 'ajaxAction',
        managerName: 'secretAjaxManager',
        rnd: Math.random()
      },
      data: `managerMethod=batchCheckUsersByReferenceSecretLevel&arguments=[${params}]`
    });
  },
  

  /**
   * 获取处理时全部附件
   * @param affairId
   * @param openFrom
   * @param designId
   * @param docId
   * @param formAttachmentIds
   * @param mainBodyAttachmentIds
   * @returns {*}
   */
  commonGetSummaryAttachments(
    affairId,
    openFrom,
    designId,
    docId,
    formAttachmentIds = '',
    mainBodyAttachmentIds = ''
  ) {
    return request({
      url: `/summary/attachments/${affairId}`,
      params: {
        openFrom,
        designId,
        docId,
        formAttrId: formAttachmentIds,
        attmentList: mainBodyAttachmentIds
      }
    });
  },
  /**
   * 页面主动关闭时候执行的解锁相关逻辑，用户提交类操作会在提交接口中执行
   * @param data
   * @returns {*}
   */
  commonPageLeave(data) {
    return request({
      url: `/new/page/leave`,
      method: 'post',
      params: {
        rnd: Math.random()
      },
      data
    });
  },
  /**
   * 协同页面心跳锁
   * @param params
   * @returns {*}
   */
  commonActiveLock(params) {
    return request({
      url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/ajax.do`,
      method: 'post',
      params: {
        method: 'ajaxAction',
        managerName: 'colManager',
        rnd: Math.random()
      },
      data: `managerMethod=activeLockTime&arguments=[${params}]`
    });
  }
});
